Java native interface array handling in a distributed java virtual machine

ABSTRACT

A method for executing native code in a distributed Java Virtual Machine (JVM) is disclosed herein. The method may include receiving, in a first thread executing in a remote execution container, a first native code-generated call, such as a Java Native Interface (JNI) call, to a second thread, the first call including a first array write request. The first call may be stored in an instruction cache and bundled with a second native code-generated call and sent to the second thread. The calls are unbundled and executed in the second thread. An opaque handle to an array returned by the second call is bundled with corresponding array data and returned to the first thread. The array data of the bundle is stored in a data cache and retrieved in response to requests for the array data addressed to the second thread. A corresponding computer program product is also disclosed.

BACKGROUND

1. Field of the Invention

This invention relates to the Java Virtual Machine, and moreparticularly to methods for executing native code in a distributed JavaVirtual Machine supporting the Java Native Interface (JNI).

2. Background of the Invention

Implementations of the Java Virtual Machine (JVM) support the JavaNative Interface (JNI) as a mechanism to enable Java bytecode to callmethods written in native code (e.g., C and C++) and vice versa.Traditionally, both the Java bytecode and the native code are executedin the same process and by the same thread as execution transitionsbetween the two.

It is possible, however, to construct a JVM to execute native code inone or more remote execution containers, which may be executed withinseparate threads on the same or different machine from where the Javabytecode is executed. In such environments, the native code may not beaware that it is executing separately from the JVM. Separating the Javabytecode and native code in this manner may help to prevent misbehavednative code from destabilizing the JVM. It may also enable the nativecode to run in a different environment (e.g., security context, bitwidth, etc.) than the JVM.

Function calls from a JNI process of a remote execution container to aJVM typically have relatively high latency, particularly for operationsin which one or both of input and output data is an array. Inparticular, function calls from the JNI to the JVM typically require atleast three round trip communications: a first call to provide an inputarray to the JVM, a second call to invoke a function operating on thearray, and a third call to request an array modified or created as aresult of the function.

In view of the foregoing, what are needed are methods to reduce thelatency of function calls from a JNI process to a remote JVM.

SUMMARY

The invention has been developed in response to the present state of theart and, in particular, in response to the problems and needs in the artthat have not yet been fully solved by currently available methods.Accordingly, the invention disclosed herein has been developed toprovide methods to execute native code in a distributed Java VirtualMachine (JVM) with low latency. The features and advantages of theinvention will become more fully apparent from the following descriptionand appended claims, or may be learned by practice of the invention asset forth hereinafter.

Consistent with the foregoing, a method for executing native code in adistributed JVM is disclosed herein. In one embodiment, such a methodincludes receiving, in a first thread in a remote execution container, afirst native code-generated call, such as a Java Native Interface (JNI)call, to a second thread in a distributed JVM, the first nativecode-generated call including a first array write request. In responseto receiving the first native code-generated call, the first nativecode-generated call is stored in an instruction cache. A second nativecode-generated call to the second thread is also received. The secondnative code-generated call may include a first function call from afirst calling function, where the first function call is not an arraywrite request. In response to receiving the second native code-generatedcall, the first and second native code-generated calls may be bundledtogether and the bundled first and second native code-generated callsmay be transmitted to the second thread.

Upon receiving the bundled first and second native code-generated calls,the second thread may then unbundle the first and second nativecode-generated calls and execute them both in the second thread. In someembodiments, the first function call may output a return valuereferencing an output array. In response to output of the return value,the return value and the output array may be bundled and transmitted tothe first thread.

Upon receiving the bundled return value and output array, the firstthread may extract the output array and store it in a data cache. Thereturn value may likewise be extracted and returned to the first callingfunction.

Other methods and implementation details are also disclosed and claimed.A corresponding computer program product is also disclosed and claimedherein.

BRIEF DESCRIPTION OF THE DRAWINGS

In order that the advantages of the invention will be readilyunderstood, a more particular description of the invention brieflydescribed above will be rendered by reference to specific embodimentsillustrated in the appended drawings. Understanding that these drawingsdepict only typical embodiments of the invention and are not thereforeto be considered limiting of its scope, the invention will be describedand explained with additional specificity and detail through use of theaccompanying drawings, in which:

FIG. 1 is a high-level block diagram showing one example of a computersystem suitable for use with various embodiments of the invention;

FIG. 2 is a high-level block diagram showing one example of anobject-oriented managed runtime, in this example the Java VirtualMachine (JVM);

FIG. 3 is a high-level block diagram showing an example of a traditionalJava Virtual Machine running both Java bytecode and native code;

FIG. 4 is a high-level block diagram of a distributed JVM with cachingand extracting layers for decreasing latency;

FIG. 5 is a process flow diagram of a method for processing an arraywrite request from native code in a distributed JVM;

FIG. 6 is a process flow diagram of a method for processing a bundledarray write request and function call in a distributed JVM;

FIG. 7 is a process flow diagram of a method for caching received arraydata in a distributed JVM;

FIG. 8 is a process flow diagram of a method for responding to arrayread requests using cached array data in a distributed JVM;

FIG. 9 is a process flow diagram of a method for managing data andinstruction caches in a distributed JVM;

FIG. 10 is a process flow diagram of a method for bundling array datawith a return value in a distributed JVM; and

FIG. 11 is a process flow diagram of an alternative method for bundlingarray data with a return value in a distributed JVM.

DETAILED DESCRIPTION

It will be readily understood that the components of the presentinvention, as generally described and illustrated in the Figures herein,could be arranged and designed in a wide variety of differentconfigurations. Thus, the following more detailed description of theembodiments of the invention, as represented in the Figures, is notintended to limit the scope of the invention, as claimed, but is merelyrepresentative of certain examples of presently contemplated embodimentsin accordance with the invention. The presently described embodimentswill be best understood by reference to the drawings, wherein like partsare designated by like numerals throughout.

As will be appreciated by one skilled in the art, the present inventionmay be embodied as an apparatus, system, method, or computer programproduct. Furthermore, the present invention may take the form of ahardware embodiment, a software embodiment (including firmware, residentsoftware, microcode, etc.) configured to operate hardware, or anembodiment combining software and hardware aspects that may allgenerally be referred to herein as a “module” or “system.” Furthermore,the present invention may take the form of a computer-usable storagemedium embodied in any tangible medium of expression havingcomputer-usable program code stored therein.

Any combination of one or more computer-usable or computer-readablestorage medium(s) may be utilized to store the computer program product.The computer-usable or computer-readable storage medium may be, forexample but not limited to, an electronic, magnetic, optical,electromagnetic, infrared, or semiconductor system, apparatus, ordevice. More specific examples (a non-exhaustive list) of thecomputer-readable storage medium may include the following: anelectrical connection having one or more wires, a portable computerdiskette, a hard disk, a random access memory (RAM), a read-only memory(ROM), an erasable programmable read-only memory (EPROM or Flashmemory), an optical fiber, a portable compact disc read-only memory(CDROM), an optical storage device, or a magnetic storage device. In thecontext of this document, a computer-usable or computer-readable storagemedium may be any medium that can contain, store, or transport theprogram for use by or in connection with the instruction executionsystem, apparatus, or device.

Computer program code for carrying out operations of the presentinvention may be written in any combination of one or more programminglanguages, including an object-oriented programming language such asJava, Smalltalk, C++, or the like, and conventional proceduralprogramming languages, such as the “C” programming language or similarprogramming languages. Computer program code for implementing theinvention may also be written in a low-level programming language suchas assembly language.

The present invention may be described below with reference to flowchartillustrations and/or block diagrams of methods, apparatus, systems, andcomputer program products according to various embodiments of theinvention. It will be understood that each block of the flowchartillustrations and/or block diagrams, and combinations of blocks in theflowchart illustrations and/or block diagrams, may be implemented bycomputer program instructions or code. The computer program instructionsmay be provided to a processor of a general-purpose computer,special-purpose computer, or other programmable data processingapparatus to produce a machine, such that the instructions, whichexecute via the processor of the computer or other programmable dataprocessing apparatus, create means for implementing the functions/actsspecified in the flowchart and/or block diagram block or blocks.

The computer program instructions may also be stored in acomputer-readable storage medium that can direct a computer or otherprogrammable data processing apparatus to function in a particularmanner, such that the instructions stored in the computer-readablestorage medium produce an article of manufacture including instructionmeans which implement the function/act specified in the flowchart and/orblock diagram block or blocks. The computer program instructions mayalso be loaded onto a computer or other programmable data processingapparatus to cause a series of operational steps to be performed on thecomputer or other programmable apparatus to produce a computerimplemented process such that the instructions which execute on thecomputer or other programmable apparatus provide processes forimplementing the functions/acts specified in the flowchart and/or blockdiagram block or blocks.

Referring to FIG. 1, one example of a computer system 100 isillustrated. The computer system 100 is presented to show one example ofan environment where techniques in accordance with the invention may beimplemented. The computer system 100 is presented only by way of exampleand is not intended to be limiting. Indeed, the techniques disclosedherein may be applicable to a wide variety of different computer systemsin addition to the computer system 100 shown. The techniques disclosedherein may also potentially be distributed across multiple computersystems 100.

The computer system 100 includes at least one processor 102 and mayinclude more than one processor. The processor 102 includes one or moreregisters 104 storing data describing the state of the processor 102 andfacilitating execution of software. The registers 104 may be internal tothe processor 102 or may be stored in a memory 106. The memory 106stores operational and executable data that is operated upon by theprocessor 102. The memory 106 may be accessed by the processor 102 bymeans of a memory controller 108. The memory 106 may include volatilememory (e.g., RAM) as well as non-volatile memory (e.g., ROM, EPROM,EEPROM, hard disks, flash memory, etc.).

The processor 102 may be coupled to additional devices supportingexecution of software and interaction with users. For example, theprocessor 102 may be coupled to one or more input devices 110, such as amouse, keyboard, touch screen, microphone, or the like. The processor102 may also be coupled to one or more output devices such as a displaydevice 112, speaker, or the like. The processor 102 may communicate withone or more other computer systems by means of a network 114, such as aLAN, WAN, or the Internet. Communication over the network 114 may befacilitated by a network adapter 116.

Referring to FIG. 2, one example of an object-oriented managed runtime,in this example a Java Virtual Machine, is illustrated. The Java VirtualMachine is presented to show one example of a runtime environment inwhich various embodiments of the invention may operate. Nevertheless,the techniques disclosed herein are not limited to the Java VirtualMachine but may operate or be adapted to operate in otherobject-oriented managed runtimes. Other non-limiting examples of runtimeenvironments in which embodiments of the invention might operate includethe Microsoft Common Language Runtime (CLR) and Smalltalk runtime. Thus,although particular reference is made herein to the Java VirtualMachine, the principles taught herein are not limited to the JavaVirtual Machine but may also be applicable to other runtimeenvironments.

As shown in FIG. 2, a Java Virtual Machine 202 may be configured tooperate on a specific platform, which may include an underlying hardwareand operating system architecture 204, 206. The Java Virtual Machine 202receives program code 200, compiled to an intermediate form referred toas “bytecode” 200. The Java Virtual Machine 202 translates this bytecode200 into native operating system calls and machine instructions forexecution on the underlying platform 204, 206. Instead of compiling thebytecode 200 for the specific hardware and software platform 204, 206,the bytecode 200 is compiled once to operate on all Java VirtualMachines 202. A Java Virtual Machine 202, by contrast, may be tailoredto the underlying hardware and software platform 204, 206. In this way,the Java bytecode 200 may be considered platform independent.

As shown, the Java Virtual Machine 202 may support the Java NativeInterface 208 as a mechanism to enable Java bytecode 200 to call methodswritten in native code (e.g., C and C++) and vice versa. Unlike the Javabytecode 200, the native code may be written for the underlying hardwareand operating system platform 204, 206. The Java Native Interface 208may allow a developer to write native methods to handle situations wherean application cannot be written entirely in the Java programminglanguage, such as when the Java class library does not supportplatform-specific features or program libraries. The Java NativeInterface 208 may also be used to modify an existing application—writtenin another programming language—to be accessible to Java applications.The Java Native Interface 208 may allow native methods to create and useJava objects in the same way that Java code creates and uses suchobjects. A native method may also inspect and use objects created byJava application code.

Referring to FIG. 3, as previously mentioned, traditionally, both theJava bytecode 200 and the native code 304 are executed in the sameprocess 300 and by the same thread 302 as execution transitions betweenthe two. FIG. 3 shows a high-level view of a traditional Java VirtualMachine (JVM) 202 a. As shown, in a single Java process 300, executionalternates between the Java bytecode 200 and the native code 304 as theJava bytecode 200 calls the native code 304 and vice versa.

Referring to FIG. 4, in a distributed environment, a distributed JVM 202b operates in conjunction with a remote execution container 400. Theremote execution container 400 may operate in a different thread,different process, or different machine than the JVM 202 b. In such anenvironment, a thread 302 executing within the distributed JVM 202 b mayexecute both local function calls and function calls received from theremote execution container. Likewise, instructions to be executed withinthe remote execution container may be invoked from within the thread 302and transmitted to the remote execution container 400. In someembodiments, instantiation of the remote execution container 400 may beinvoked by the JVM 202 b, such as by an instruction within the thread302. Alternatively, a remote execution container 400 may be instantiatedmanually or according to some other process and linked or otherwisepresented to the JVM 202 b for use.

The remote execution container 400 may execute a process 402 includingone or more threads 404. A native module 406 may execute within thethread 404. The native module 406 may include native code invoked by,and interacting with the thread by means of, the Java Native Interface(JNI) implemented by the thread 404. Native code functions may beinvoked through the JNI to be executed by the native module 406.Likewise, the native module 406 may invoke Java functions through theJNI to be executed by the distributed JVM 202 b in a thread 302 or someother process.

In the illustrated embodiment, the remote execution container 400includes a caching layer 408 that has an instruction cache 410 and adata cache 412 associated therewith. The caching layer 408 representsfunctionality of the remote execution container 400 for processinginstructions passing to and from the remote execution container 400 andmay or may not be embodied as an actual distinct module or logicalgrouping of instructions or functionality. The distributed JVM 202 b mayinclude an extraction/bundling layer 414. The extraction/bundling layer414 likewise represents functionality of the distributed JVM 202 b forprocessing instructions passing to and from the distributed JVM 202 band may or may not be embodied as an actual distinct module or logicalgrouping of instructions or functionality.

The functionality of the caching layer 408 and extraction/bundling layer414 will be discussed in extensive detail hereinbelow. In particular,the caching layer 408 may implement functionality discussed hereinbelowrelating to caching of outgoing array write requests from the remoteexecution container 400, bundling cached requests with JNI function callrequests to be sent to the distributed JVM 202 b, and caching incomingdata received from the distributed JVM 220 b. Likewise, theextraction/bundling layer 414 may implement functionality discussedhereinbelow relating to extracting array write requests and other JNIfunction call requests from bundles received from the remote executioncontainer 400 and bundling array data with return values to be sent tothe remote execution container 400.

The methods disclosed herein reduce latency due to array write and readrequests. Example of JNI callbacks that may advantageously processedaccording to the methods disclosed herein include:GetBooleanArrayRegion, GetByteArrayRegion, GetCharArrayRegion,GetShortArrayRegion, GetIntArrayRegion, GetLongArrayRegion,GetFloatArrayRegion, GetDoubleArrayRegion, SetBooleanArrayRegion,SetByteArrayRegion, SetCharArrayRegion, SetShortArrayRegion,SetIntArrayRegion, SetLongArrayRegion, SetFloatArrayRegion,SetDoubleArrayRegion, GetBooleanArrayElements, GetByteArrayElements,GetCharArrayElements, GetShortArrayElements, GetIntArrayElements,GetLongArrayElements, GetFloatArrayElements, GetDoubleArrayElements,ReleaseBooleanArrayElements, ReleaseByteArrayElements,ReleaseCharArrayElements, ReleaseShortArrayElements,ReleaselntArrayElements, ReleaseLongArrayElements,ReleaseFloatArrayElements, and ReleaseDoubleArrayElements.

FIG. 5 illustrates a method 500 for processing instructions receivedfrom, for example, a native module 406 executing native code. Theinstructions may be Java instructions received through a JNI implementedin a remote execution container 400. Accordingly, the method 500includes receiving 502 a JNI function call request. If the JNI functioncall request is determined 504 to be an array write request, then therequest may be stored 506 in the instruction cache 410. Multiple arraywrite requests may be stored 506 in the instruction cache 410 before thecontents of the cache are transmitted to the distributed JVM 202 b, suchas for execution in a thread 302.

If the JNI function call request is determined 504 to be an requestother than an array write request, then the method 500 may evaluate 508whether the instruction cache 410 is empty. If so, the JNI function callrequest may be transmitted 510 to the distributed JVM 202 b forprocessing. If not, any JNI function call requests in the instructioncache 410 may be bundled 512 with the received JNI function call requestand the bundle may be transmitted 514 to the distributed JVM forprocessing. The above functionality reduces latency by omitting theround trip required to transmit the array to the distributed JVM 202 b.

In some embodiments, a calling function that generates an array writerequest may expect a return value or other acknowledgment oftransmission of the array and may hang until such acknowledgment isreceived. In such embodiments, storing 506 the array transmit request inthe instruction cache may additionally include returning a return valueor acknowledgment confirming transmission to the calling function.

FIG. 6 illustrates a method 600 for processing JNI function callrequests or bundles of JNI function call requests received by adistributed JVM 202 b from a remote execution container 400. The method600 includes receiving 602 an JNI function call request from thedistributed execution container 400 and evaluating 604 whether the JNIfunction call request is a bundle of JNI function call requests. If so,then any array write requests and any other function calls are extracted606 from the bundle. In either case, the JNI function call request orbundle of JNI function call requests are executed 608. Executing 608 theJNI function call requests in the bundle may be performed within thethread 302 of the distributed JVM 202 b.

Where the bundle includes array write requests, the arrays included inthe requests may first be written to a memory space or used to overwritearray data for an array specified in the request. The JNI function callrequest included in the bundle may be executed after the array data hasbeen written to the memory space or overwritten existing array data.This ordering may be used to ensure that, upon execution, the functioncall identified in the JNI function call request is operating on currentdata.

A return value of the function call may be evaluated 610. If the returnvalue is not an array or opaque handle to an array or array object, thereturn value may be transmitted 612 to the remote execution container400 for return to the thread 404 and corresponding native module 406. Ifthe output is an array, typically embodied as an opaque handle to anarray or array object, then the array data and the return value may bebundled 614 and the bundle transmitted 616 to the remote executioncontainer 400 for return to the thread 404 and corresponding nativemodule 406.

FIG. 7 illustrates a method 700 for processing data returned from adistributed JVM 202 b to a remote execution container 400. The returndata may be received 702 and evaluated 704 to determine whether thereturn data is a return value or a bundle. If the return data is abundle, then array data may be extracted and stored 706 in the datacache 412. In either case, a return value in the return data may beforwarded 708 to a calling function, such as by forwarding the returnvalue to a calling function in the native module 406 executing withinthe thread 404.

FIG. 8 illustrates a method 800 for using cached array data. The method800 includes receiving 802 an array read request, which may includereceiving any type of array read request. The request to read array datamay be received by the thread 404 from the native module 406 andintercepted by the caching layer 408.

The request to read array data may be evaluated 804 with respect toarray data stored in the data cache 412. If the array data correspondingto the request is found 804 to be stored in the data cache 412, then thearray data is retrieved 806 from the cache and returned 808 to therequesting function, such as a function within the native module 406executed within the thread 404. If the requested array data is not found804 to be stored in the data cache 412, then the request for array datamay be transmitted 810 to the distributed JVM 202 b and processed toretrieve the requested data. This may include retrieving the data usingthe thread 302. The requested data is then transmitted to the remoteexecution container 400, which receives 812 the array data. The receivedarray data may be stored 814 in the data cache 412 and returned 808 tothe requesting function.

The method 800 advantageously omits a round trip required to retrievethe array data inasmuch as the array data may have been previouslyreceived in a bundle with a return value pointing to the arraycontaining the array data.

FIG. 9 illustrates a method 900 for managing data and instruction cachesto maintain data consistency. The method 900 includes intercepting 902 aJNI function call request, such as a JNI function call requestoriginating from a native module 406. If the JNI function call requestis found 904 to be an array write request, then the JNI function callrequest may be processed 906 according to the methods disclosed hereinfor processing array write requests. For example processing 906 mayinclude executing the method 500. In some embodiments, processing 906 awrite request referencing an array may include updating datacorresponding to that array in the data cache 412 so that the data cache412 is kept current. If the intercepted instruction is determined 904 tobe other than an array write or read request, then the instruction cache410 may be flushed 908. Flushing 908 the instruction cache 410 mayinclude bundling any array transmit instructions in the cache 410 withthe intercepted 902 JNI function call request.

The method 900 may further include evaluating 910 whether the JNIfunction call request is an array read request. If so, then the arrayread request may be processed 912 according to methods disclosed herein,such as according to the method 800. If the intercepted JNI functioncall request is not found 910 to be an array read request, the datacache 412 may be cleared 914. Clearing 914 the data cache 412 mayinclude deleting cached arrays and array data from the cache or simplymarking stored array data as invalid or stale.

The intercepted JNI function call request may be forwarded 916 to thedistributed JVM, such as to the thread 302 executing in the distributedJVM 202 b. This may include forwarding a bundle including both theintercepted JNI function call request and any cached array transmitrequests flushed 908 from the instruction cache 410.

As noted above, the method 900 may be used to ensure data consistency.In particular, the method 900 may be used in some embodiments to ensureconsistency of data operated upon by multiple threads. To ensurethreadsafe operation a developer may include special code ensuring thatcertain operations are performed according to a given order amongdifferent threads or to ensure that no changes to operational data areperformed at critical stages in a program. These coordinating stepstypically require a function call from the native module through theJNI. Accordingly, by flushing an instruction cache and clearing a datacache for JNI function call requests according to the method 900, writeinstructions may advantageously be executed and invalid data purged tofacilitate threadsafe operation in response to these function calls forcoordinating multithreaded operation. In particular, the “MonitorEnter”and “MonitorExit” function calls in Java may trigger flushing andclearing of caches and thereby facilitate consistent data betweenthreads. In some embodiments, one or both of the instruction and datacaches may be flushed or cleared in response to JNI function callrequests that will require the execution of Java code. In suchembodiments, JNI function call requests that will not invoke theexecution of Java code in the Distributed JVM may be processed such thatthey do no trigger flushing of the instruction cache or clearing of thedata cache.

In some embodiments, native code may require data consistency betweendifferent threads where Java callbacks are not generated to coordinateoperation. This may be the case where native code modules operating inseparate threads are operating on data in the same memory space. In suchembodiments, a developer may flag modules or functions that operate inthis manner as ineligible for one or both of caching write instructionsand caching received array data or using cached array data according tothe methods described herein. In some embodiments, such functions ormodules may be detected upon compilation, loading for execution, orexecution, and flagged as ineligible at this time. Any other function ormodule that a developer wishes not to take advantage of methodsdisclosed herein may also be flagged as ineligible. One or both of thecaching layer 408 and the extraction and bundling layer 414 may evaluatesuch flags and function accordingly. In some embodiments, a developer oruser may specify that a distributed JVM in its entirety or an entireapplication operating on a distributed JVM is not to perform thelatency-reducing methods described herein.

Referring to FIG. 10, the methods disclosed herein are particularlyuseful where the time required to transmit an array between thedistributed JVM 202 b and the remote execution container 400 is on theorder of the latency of communication therebetween. Where the arraytransferred is very large, the methods disclosed herein may introducedelays. Accordingly, the method 1000 may be used to help avoid suchdelays.

The method 1000 may include executing 1002 a JNI function call requestin a distributed JVM 202 b, such as within a thread 302. If the returnvalue of the function call of the JNI function call request is found1004 to be an array or opaque handle to an array, the size of the arraymay be evaluated 1006. If the array size is larger than a threshold orthe return value of the instruction is not an array, the return value1008 may be returned to the remote execution container 400, such as forprocessing by the native module 406 executing within a thread 404.

If the size of the array corresponding to the return value is not found1006 to be larger than a threshold value, then the array and returnvalue may be bundled 1010 and transmitted 1012 to the remote executioncontainer 400 for processing according to the methods disclosed herein,such as the method 700.

FIG. 11 illustrates an alternative method 1100 for dealing with largearrays. The method 1100 may include executing 1102 a JNI function callrequest in a distributed JVM 202 b, such as within a thread 302. If thereturn value of the function call of the JNI function call request isnot found 1104 to be an array or opaque handle to an array, the returnvalue 1106 may be returned to the remote execution container 400, suchas for processing by the native module 406 executing within a thread404.

If the return value is found to be an array or opaque handle to anarray, the size of the corresponding array may be evaluated 1108. If thearray size is found 1108 to be smaller than a threshold size, the arraymay be bundled 1110 with the return value and transmitted 1112 to theremote execution container 400 for processing according to the methodsdisclosed herein, such as the method 700.

If the array size is found 1108 to be larger than the threshold size,the method 1100 may evaluate 1114 prior access to the array, if any. Ifprior access, if any, is found 1116 to indicate that a particular areaof the array referenced by the return value is an active region, thenthe active region, or a portion of the array that has a size accordingto the threshold and includes some or all of the active region, may bebundled 1118 with the return value for transmission 1112 to the remoteexecution container as already discussed. If there is no apparent activeregion, then the return value may be returned 1106 without any arraydata.

Various modifications and alternatives to the method 1100 may also beused. For example, an apparent active region may be identified based onactual accesses to an array. This may include evaluating a region of anarray identified in requests to retrieve array data. Once one or more ofthese requests have been received, the requested region of the mostrecent or an aggregation of the requested regions for multiple recentrequests, may be used as the active region. Alternatively, where no dataor sparse data exists for usage of an array, an apparent active regionmay be inferred from usage of other arrays. For example, if a pattern isapparent that only the first N values of large arrays are used mostfrequently, then the first values of an array up to the threshold sizemay be used as the apparent active region for the array.

The flowcharts and block diagrams in the Figures illustrate thearchitecture, functionality, and operation of possible implementationsof systems, methods, and computer-usable media according to variousembodiments of the present invention. In this regard, each block in theflowcharts or block diagrams may represent a module, segment, or portionof code, which comprises one or more executable instructions forimplementing the specified logical function(s). It should also be notedthat, in some alternative implementations, the functions noted in ablock may occur out of the order noted in the Figures. For example, twoblocks shown in succession may, in fact, be executed substantiallyconcurrently, or the blocks may sometimes be executed in the reverseorder, depending upon the functionality involved. Some blocks may bedeleted or other blocks may be added depending on the functionalityinvolved. It will also be noted that each block of the block diagramsand/or flowchart illustrations, and combinations of blocks in the blockdiagrams and/or flowchart illustrations, may be implemented by specialpurpose hardware-based systems that perform the specified functions oracts, or combinations of special purpose hardware and computerinstructions.

1-10. (canceled)
 11. A computer program product to execute native codein a distributed Java Virtual Machine (JVM), the computer programproduct comprising a computer-readable storage medium havingcomputer-usable program code embodied therein, the computer-usableprogram code comprising: computer-usable program code to receive, in afirst thread, a native code-generated call to a second thread, the firstnative code-generated call including a first array write instruction,the first thread executing in a remote execution container with respectto the second thread; computer-usable program code to, in response toreceipt of the first native code-generated call, store the first nativecode-generated call in an instruction cache; computer-usable programcode to receive, in the first thread, a second native code-generatedcall to the second thread, the second native code-generated callincluding a first function call, that is not an array write instruction,from a first calling function; and computer-usable program code to, inresponse to receipt of the second native code-generated call, bundle thefirst and second native code-generated calls and transmit the bundledfirst and second native code-generated calls to the second thread. 12.The computer program product of claim 11, further comprisingcomputer-usable program code to: receive the bundled first and secondnative code-generated calls in a second thread; unbundle the first andsecond native code-generated calls; execute the first array writeinstruction in the second thread; and execute the first function call inthe second thread.
 13. The computer program product of claim 12, furthercomprising computer-usable program code to: output from the firstfunction call a return value referencing an output array; in response tooutput of the return value, bundle the return value and the outputarray; and transmit the bundled return value and output array to thefirst thread.
 14. The computer program product of claim 13, furthercomprising computer-usable program code to: extract, in the firstthread, the output array and return value from the bundled return valueand output array; store the output array in a data cache; and return thereturn value to the first calling function.
 15. The computer programproduct of claim 14, further comprising computer-usable program code to:receive, in the first thread, a third native code-generated callincluding an array read request to access the output array; interceptthe native code-generated call in the first thread; and return theoutput array from the data cache in response to the array read request.16. The computer program product of claim 14, further comprisingcomputer-usable program code to: receive, in the first thread, a thirdnative code-generated call including a second function call that is notan array write or array read request; and in response to receiving thethird native code-generated call, clear the data cache.
 17. The computerprogram product of claim 14, further comprising computer-usable programcode to: in response to receiving the third native code-generated call,transmit any instructions stored in the instruction cache to the secondthread.
 18. The computer program product of claim 12, further comprisingcomputer-usable program code to: output from the first function call areturn value referencing an output array; in response to output of thereturn value, evaluate a size of the output array; and if the size ofthe output array does not exceed a size threshold, transmit a bundleincluding the return value and the output array to the first thread,otherwise, transmit the return value to the first thread.
 19. Thecomputer program product of claim 12, further comprising computer-usableprogram code to: output from the first function call a return valuereferencing an output array; in response to output of the return value,evaluate a size of the output array; and if the size of the output arrayexceeds a size threshold, identify an active region of the output arrayand transmit a bundle including the return value and the active regionto the first thread, otherwise, transmit a bundle including the returnvalue and the output array to the first thread.
 20. The computer programproduct of claim 11, further comprising computer-usable program code to:receive, in the first thread a third native code-generated call to thesecond thread, the third native code-generated call including a secondarray write instruction, the third native code-generated call receivedafter the first native code-generated call but before the second nativecode-generated call; in response to receipt of the third nativecode-generated call, store the third native code-generated call in theinstruction cache; and wherein the computer-usable program code tobundle the first and second native code-generated call and transmit thebundled first and second native code-generated call to the second threadis further operable to bundle the first, second, and third nativecode-generated calls and transmit the bundled first, second, and thirdnative code-generated calls to the second thread.